﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using ComLib.ComFun;
using System.IO;
using LogLib;
using ComLib.ConfigService;

namespace ProcessConfig.ConfigType
{
    [XmlRootAttribute("NoSupportOption", Namespace = "ProcessConfig.ConfigType", IsNullable = false)]
    public class NoSupportOption : XmlSerializeBase
    {
        public NoSupportOption()
        {

        }

        /// <summary>
        /// 是否启用提示不支持选项功能
        /// </summary>
        private bool _enabled = false;
        public bool Enabled
        {
            get { return _enabled; }
            set { _enabled = value; }
        }

        /// <summary>
        /// 激活功能的错误提示次数
        /// </summary>
        private int _errorActivationTimes  = 10;
        public int ErrorActivationTimes
        {
            get { return _errorActivationTimes; }
            set { _errorActivationTimes = value; }
        }

        /// <summary>
        /// 是否提示前面等待人数
        /// </summary>
        private string _adviceContent = "请咨询工作人员，使用人工拍照方式";
        public string AdviceContent
        {
            get { return _adviceContent; }
            set { _adviceContent = value; }
        }

        public override bool Serialize()
        {          
            return Serializer.SaveToXml(ConfigFilePath, this);
        }

      
        public override bool Load()
        {
            NoSupportOption obj = (NoSupportOption)Serializer.LoadFromXml(ConfigFilePath, this.GetType());
            if (obj != null)
            {
                this._adviceContent = obj._adviceContent;
                this._enabled = obj._enabled;
                this._errorActivationTimes = obj._errorActivationTimes;
                this._nVer = obj._nVer;
                return true;
            }
            else
            {
                ErrorMessage = Serializer.Message;
                return false;
            }
        }

        public override string ToString()
        {
            if (!_enabled)
            {
                return "[不支持提示选项]功能未启用; ";
            }
            StringBuilder builder = new StringBuilder("不支持提示选项: ");
            builder.Append("[错误次数激活]:" + _errorActivationTimes.ToString());
            builder.Append("[建议内容]:" + _adviceContent);  
            return builder.ToString();
        }
    }
}
